package service;


import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Component("LogAspect")
@Aspect
@Order(2)
public class LogAspect {//切面

    //切面等于通知+切入点
    //通知就是增强，就是具体的增强代码
    //@Before
    @Before("execution(* service.UserService.*(..))")
    public void before(){
        System.out.println("before:log");
    }

    @AfterReturning("execution(* service.UserService.*(..))")
    public void afterReturning(){
    	System.out.println("afterReturning");
    }

    @Around("execution(* service.UserService.*(..))")
    public void around(ProceedingJoinPoint joinPoint) throws Throwable {
    	System.out.println("前置环绕");

        joinPoint.proceed();
        System.out.println("后置环绕");
    }

    @After("execution(* service.UserService.*(..))")
    public void after(){
    	System.out.println("最终通知");
    }
}
